package train.DAY623;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Test623 {
    public static void main(String[] args) {
//        Pattern pattern = Pattern.compile("[1-9][0-9]{4,}");
//        String a="329";
//        Matcher pattern1 = pattern.matcher(a);
//        while(pattern1.find()){
//            System.out.println(pattern1.start()+"\t"+ pattern1.end());
//
//        }




    }


    public static void main1(String[] args) {
        String regex = "(Geeks)";
        Pattern pattern = Pattern.compile(regex);

        String stringToBeMatched   = "GeeksForGeeks Geeks for For Geeks Geek";
        Matcher matcher = pattern.matcher(stringToBeMatched);

       // System.out.println("After Replacement: " + matcher   .replaceAll("Duck"));


        System.out.println("matcher = " +    stringToBeMatched.replaceAll("(Geeks)","Duck") );


    }

    public static void main3 (String[] args) {
//        0    (\d{4})-((\d{2})-(\d{2}))  2017-04-25
//        1    (\d{4})    2017
//        2    ((\d{2})-(\d{2}))  04-25
//        3    (\d{2})    04
//        4    (\d{2})    25


        String DATE_STRING = "2017-04-25";
        String P_COMM = "(\\d{4})-((\\d{2})-(\\d{2}))";

        Pattern pattern = Pattern.compile(P_COMM);
        Matcher matcher = pattern.matcher(DATE_STRING);
        matcher.find();//必须要有这句
        System.out.printf("\nmatcher.group(0) value:%s", matcher.group(0));
        System.out.printf("\nmatcher.group(1) value:%s", matcher.group(1));
        System.out.printf("\nmatcher.group(2) value:%s", matcher.group(2));
        System.out.printf("\nmatcher.group(3) value:%s", matcher.group(3));
        System.out.printf("\nmatcher.group(4) value:%s", matcher.group(4));
    }

    
}
